package com.ccmusic.dao.impl;

import java.util.List;

import com.ccmusic.dao.TypeDao;
import com.ccmusic.entity.Music;
import com.ccmusic.entity.MusicType;
import com.ccmusic.entity.Type;

public class TypeDaoImpl extends BaseDao implements TypeDao {
    /**
     * 重写Typedao中的addType方法
     */
	@Override
	public boolean addType(Type type) {
		String sql="insert into type(tname) values(?)";
		return this.execute(sql, type.getTname())>0;
	}
    /**
     * 重写Typedao中的deleteType方法
     */
	@Override
	public boolean deleteType(String tname) {
		String sql="delete from type where tname =?";
		return this.execute(sql, tname)>0;
	}
    /**
     * 重写Typedao中的deleteType方法
     */
	@Override
	public List<MusicType> getMusicByType(String tname) {
		String sql="select * from musicType where tname like ?";
        List<MusicType> list=(List<MusicType>)this.select(sql,MusicType.class, "%"+tname+"%");
        if(list.size()!=0){
        	return list;
        }else {
        	return null;
        }
        
	}

}
